package org.smartboot.flow.example;

import org.smartboot.flow.manager.reload.XmlSelector;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

/**
 * @author huqiang
 * @since 2022/12/7 19:54
 */
@Service("xxxxSelector")
@Primary
public class MockXmlSelector implements XmlSelector {

    @Override
    public String select(String engineName) {
        return "<engines>\n" +
                "    <engine name=\"testEngine\" pipeline=\"subprocess1\"/>\n" +
                "\n" +
                "    <pipeline name=\"subprocess9\">\n" +
                "        <component execute=\"org.smartboot.flow.example.AsyncStep1\" name=\"step100\" rollback=\"true\"/>\n" +
                "        <component execute=\"org.smartboot.flow.example.AsyncStep2\" name=\"step102\"/>\n" +
                "    </pipeline>\n" +
                "\n" +
                "    <pipeline name=\"subprocess1\">\n" +
                "        <component execute=\"org.smartboot.flow.example.Step2\" name=\"step2\" rollback=\"true\"/>\n" +
                "        <component execute=\"selfCallbackComponent\" name=\"step112\" degradable=\"true\"/>\n" +
                "        <component subprocess=\"subprocess9\"/>\n" +
                "        <pipeline name=\"subprocess2\">\n" +
                "            <component execute=\"step3\" name=\"step3\" rollback=\"true\"/>\n" +
                "            <component execute=\"step4\" name=\"step4\"/>\n" +
                "        </pipeline>\n" +
                "\n" +
                "        <adapter execute=\"org.smartboot.flow.example.AdapterTest\" name=\"testAdapter\">\n" +
                "            <component execute=\"org.smartboot.flow.example.NewStep1\" name=\"newstep1\"/>\n" +
                "            <component execute=\"org.smartboot.flow.example.NewStep1\" name=\"newstep2\"/>\n" +
                "        </adapter>\n" +
                "        <if test=\"ifCondition\">\n" +
                "            <then>\n" +
                "                <component execute=\"step5\" name=\"step5\"/>\n" +
                "                <component execute=\"step6\" name=\"step6\"/>\n" +
                "                <pipeline name=\"subprocess3\">\n" +
                "                    <if test=\"ifCondition2\">\n" +
                "                        <then execute=\"asyncStep1\" name=\"step7\"/>\n" +
                "                    </if>\n" +
                "                    <component execute=\"asyncStep2\" name=\"step8\"/>\n" +
                "                </pipeline>\n" +
                "            </then>\n" +
                "            <else execute=\"defaultStep\" name=\"default\"/>\n" +
                "        </if>\n" +
                "        <choose test=\"chooseCondition\">\n" +
                "            <case when=\"1\">\n" +
                "                <component execute=\"integerStep\" name=\"step9\"/>\n" +
                "                <component execute=\"asyncStep3\" name=\"step10\"/>\n" +
                "            </case>\n" +
                "            <case when=\"null\" execute=\"nullStep\" degradable=\"false\" degrade-callback=\"exampleCallback\"/>\n" +
                "            <default execute=\"defaultStep\"/>\n" +
                "        </choose>\n" +
                "\n" +
                "        <if test=\"alwaysFalseCondition\">\n" +
                "            <then>\n" +
                "                <component execute=\"step5\" name=\"step5\"/>\n" +
                "                <component execute=\"step6\" name=\"step6\"/>\n" +
                "            </then>\n" +
                "        </if>\n" +
                "    </pipeline>\n" +
                "\n" +
                "    <script name=\"alwaysFalseCondition\" type=\"javaScript\">\n" +
                "        var local = 2;\n" +
                "        local == request;\n" +
                "    </script>\n" +
                "\n" +
                "</engines>";
    }
}
